using System.Data;
using ET;

namespace DAL
{
    public class Part_DAL
    {
        private static readonly clsConnect cls = new clsConnect();
        #region Getdata
        public DataTable BindGirdtb_Part(string keywords)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@KeyWords", keywords);
            return cls.GetData("sp_tb_Part_Search");
        }
        public DataTable BindGirdtb_PartDetail(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Part_ID", id);
            return cls.GetData("sp_tb_Part_Detail");
        }
        #endregion

        #region Insert
        public bool Inserttb_Part(Part_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Part_Alias", data.Part_Alias);
            cls.AddParameter("@Part_Name", data.Part_Name);
            cls.AddParameter("@Part_Note", data.Part_Note);
            cls.AddParameter("@Part_User_Add", data.Part_User_Add);
            cls.AddParameter("@Part_Date_Add", data.Part_Date_Add);
            cls.AddParameter("@Part_Computer_Add", data.Part_Computer_Add);
            return cls.ExecuteNonQuery("sp_tb_Part_Insert");
        }
        #endregion

        #region Update
        public bool Updatetb_Part(Part_ET data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Part_ID", data.Part_ID);
            cls.AddParameter("@Part_Alias", data.Part_Alias);
            cls.AddParameter("@Part_Name", data.Part_Name);
            cls.AddParameter("@Part_Note", data.Part_Note);
            cls.AddParameter("@Part_User_Modify", data.Part_User_Modify);
            cls.AddParameter("@Part_Date_Modify", data.Part_Date_Modify);
            cls.AddParameter("@Part_Computer_Modify", data.Part_Computer_Modify);
            return cls.ExecuteNonQuery("sp_tb_Part_Update");
        }
        #endregion

        #region Delete
        public bool Deletetb_Part(int id)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Part_Id", id);
            cls.ExecuteNonQuery("sp_tb_Part_Delete");
            return true;
        }
        #endregion
    }
}